/**
  ******************************************************************************
  * @file    var_tbl.c
  * @author  Dajin Li
  * @version V0.0.1
  * @date    08-08-2015 
  * @brief   This file contains CANopen specific functions. 
  *			  	 
  *          
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; KION(SZ) R&D Center
  *
  * Licensed under KION, (the "License");
  *
  ******************************************************************************
  */
/* Includes ------------------------------------------------------------------*/
#include "var_tbl.h"
#include "can.h"
#include "can_open.h"

char hardware_id[12] = {0x30, 0x30,0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,  0x30, 0x00};
u32 software_version = 1; 
u16  diag_version;
char serial_number[16] = {0x30, 0x30, 0x30, 0x30, 0x30, 0x30,0x30, 0x30, 0x30,0x30, 0x30, 0x30,0x30, 0x30, 0x30, 0x00};
char last_part_number[12];
u8 software_module = 0x00; // 0x01, applicaiton, 0x00 bootblock, 0x05 KudOS,
char part_number[12] = {0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00};
u32 seed_3;
u32 key_4 = 0;
u32 seed_5;
u32 key_6 = 0;
char ecu_name[8] = {'D', 'I', 'S', 'P', 'L', 'A','Y', 0x00};

/* Private variables ---------------------------------------------------------*/
static s16 first_variable = {0};
static s16 last_variable = {0};
char software_id[] = "411429165748";
char software_id_app[] = "411429165748";


const s16 MAX_KWP_ECU_OBJECT_DEF = 11;

kwp_data_st kwp_ecu_params[] = 
{
  { &(hardware_id),              0x0B,     0,    0x80,    0, 0, 0 },      // 0,  hardware id
  { &(software_id_app),          0x0C,     0,    0x81,    0, 0, 0 },      // 1,  applicaiton software id
  { &(software_version),         0x02,     0,    0x84,    0, 0, 0 },      // 2,  software version
  { &(ecu_name),                 0x03,     0,    0x85,    0, 0, 0 },      // 3,  ECU name,
  { &(software_id),              0x0C,     0,    0x86,    0, 0, 0 },      // 4,  boot software id
  { &(diag_version),             0x02,     0,    0x87,    0, 0, 0 },      // 5,  diag version
  { &(serial_number),            0x0F,     0,    0x88,    0, 0, 0 },      // 6,  hardware serial number
  { &(last_part_number),         0x0B,     0,    0x89,    0, 0, 0 },      // 7,  last part number
  { &(software_module),          0x01,     0,    0x8A,    0, 0, 0 },      // 8,  software modules,
  { &(first_variable),           0x00,     0,    0x8B,    0, 0, 0 },      // 9,  reserved
  { &(first_variable),           0x00,     0,    0x8C,    0, 0, 0 },      // 10, reserved
  { &(last_variable),            0,        0,    0,       0, 0, 0 }       //
};

const s16 MAX_KWP_DATA_OBJECT_DEF = 5;

kwp_data_st kwp_data_params[] = 
{
//    // Var                attr      ee_addr   id      min    max       default
    { &(part_number),       0x880B,     0,     0x00,    0,     0,        0,    },// 0,   part number
    { &(serial_number),     0x880F,     13,    0x10,    0,     0,        0,    },// 1,  display_serial number
    { &(date_code),         0x8802,     28,    0x11,    0,     0,        0,    },// 2,  date code
    { &(hardware_id),       0x880B,     32,    0x19,    0,     0,        0,    },// 3,  reserved
    { &(last_part_number),  0x880B,     55,    0x1B,    0,     0,        0,    },// 27,  reserved
    { &(last_variable),  0,          0,		0,	     0,     0,        0,    }                      // null
};                                                                                                      




